/*******************************************************************************
*  file    : main.cpp
*  created : 06.05.2013
*  author  : 
*******************************************************************************/

#include "uzmainwindow.h"
#include <QApplication>
#include <QTextCodec>
#include <qlogger.hpp>

namespace {
QLogger* l_ = QLoggerEngine::getLogger("core");
}
void set_codecs();

int main(int argc, char *argv[])
{
    int app_res = 0;
    try
    {
        QApplication a(argc, argv);
        set_codecs();
        QLoggerConsoleAppender* con_apdr =
                new QLoggerConsoleAppender(LevelAll,stdout,"%d\t<%l>\t{%c}\t%m%n", "hh:mm:ss");
        l_->addAppender(con_apdr);
        logInfo(l_)<<"UZ started.";
        uzMainWindow w;
        w.show();

        app_res = a.exec();
        logInfo(l_)<<"UZ stoped.";
    }
    catch(...)
    {
        logError(l_,QString("Unexpected Error!"));
        app_res = 0xa11bad;
    }
    return app_res;
}

void set_codecs()
{
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
#endif
#ifdef Q_OS_WIN
QTextCodec::setCodecForLocale(QTextCodec::codecForName("CP-866"));
#endif
}
